package com.zzyl.controller.manager.nursing;

import com.zzyl.base.PageBean;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingProjectDto;
import com.zzyl.dto.NursingProjectPageQueryDto;
import com.zzyl.entity.nursing.NursingProject;
import com.zzyl.service.NursingProjectService;
import com.zzyl.vo.NursingProjectVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "护理项目管")
@RestController
@RequestMapping("/nursing_project")
@RequiredArgsConstructor
public class NursingProjectController {
    private final NursingProjectService ns;
/*
* NursingProject
* 分页查询
* */
    @GetMapping
    @ApiOperation("分页查询")
    public ResponseResult papegetlist(Integer pageNum, Integer pageSize, String name, Integer status){
        PageBean<NursingProjectVo> pb = ns.papegetlist(pageNum, pageSize, name, status);
        return ResponseResult.success(pb);
        
    }
    @PostMapping
    @ApiOperation("新增")
    public ResponseResult insertgetNursingProject(@RequestBody NursingProjectVo nursingProjectVo){
        ns.insertgetNursingProject(nursingProjectVo);
        return ResponseResult.success();
    }
    /*
    * 根据id查询
    * */
    @GetMapping("/{id}")
    @ApiOperation("详情")
    public ResponseResult getidlist(@PathVariable("id") Long id){
        NursingProjectVo nursingProjectVo = ns.getidlist(id);
        return ResponseResult.success(nursingProjectVo);
    }
    @PutMapping
    @ApiOperation("编辑")
    public ResponseResult updatestate(@RequestBody NursingProjectVo nursingProjectVo){
         ns.updatestate(nursingProjectVo);
        return ResponseResult.success();
    }

    /*
    * 启用禁用
    * */
    @PutMapping("/{id}/status/{status}")
    @ApiOperation("启用禁用")
    public ResponseResult getidandstatus(@PathVariable Long id, @PathVariable Integer status){
        ns.getidandstatus(id,status);
        return ResponseResult.success();
    }
    /*
    * 根据id删除字段
    * */
    @DeleteMapping("/{id}")
    @ApiOperation("删除")
    public ResponseResult deleteidstatus(@PathVariable Long id){
        ns.deleteidstatus(id);
        return ResponseResult.success();
    }
    @GetMapping("/all")
    @ApiOperation("查询所有")
    public ResponseResult getidnursingStatus(){
        List<NursingProject> ndursingStatus = ns.getidnursingStatus();
        return ResponseResult.success(ndursingStatus);
    }
    
}
